package com.rodagroup.study.modules.grpc.demo.provider.app;

import com.rodagroup.study.modules.grpc.demo.provider.app.internal.impl.HelloInternalService;
import io.grpc.Server;
import io.grpc.ServerBuilder;
import lombok.extern.slf4j.Slf4j;

import java.net.InetAddress;

/**
 * @author jake, {@literal <jake.kim@rodagroup.cn>}
 * @date 2022-07-07.
 */
// https://yidongnan.github.io/grpc-spring-boot-starter/zh-CN/server/testing.html
@Slf4j
public class GrpcServer {

  private static final int PORT = 9999;
  public static void main( String[] args ) throws Exception {
    String address = InetAddress.getLocalHost().getHostAddress();
    Server server = ServerBuilder.forPort(PORT)
        .addService( new HelloInternalService() )
        .build().start();
    log.info("grpc server started and is running on {} : {}", address, PORT);
    server.awaitTermination();
  }

}
